package meta.codeanywhere.util;

import java.net.URI;

import javax.tools.SimpleJavaFileObject;
/**
 * 
 */

/**
 * @author Jave 2 SE
 * @date 2006-7-15
 */       
public class JavaSourceFromString extends SimpleJavaFileObject {
     /**
      * The source code of this "file".
      */
     private final String code;

     /**
      * Constructs a new JavaSourceFromString.
      * @param name the name of the compilation unit represented by this file object
      * @param code the source code for the compilation unit represented by this file object
      */
     public JavaSourceFromString(String name, String code) {
         super(URI.create("string:///" + name.replace('.','/') + Kind.SOURCE.extension),
               Kind.SOURCE);
         this.code = code;
     }

     @Override
     public CharSequence getCharContent(boolean ignoreEncodingErrors) {
         return code;
     }
 }
